//store/actionCreators.js
import { getSongDetailRequest } from '@/api/request';
import {
  SET_CURRENT_SONG,
  SET_FULL_SCREEN,
  SET_PLAYING_STATE,
  SET_SEQUECE_PLAYLIST,
  SET_PLAYLIST,
  SET_PLAY_MODE,
  SET_CURRENT_INDEX,
  SET_SHOW_PLAYLIST,
  DELETE_SONG,
  INSERT_SONG,
} from './constants';

export const changeCurrentSongAction = (data) => ({
  type: SET_CURRENT_SONG,
  currentSong: data,
});

export const changeFullScreenAction = (data) => ({
  type: SET_FULL_SCREEN,
  fullScreen: data,
});

export const changePlayingStateAction = (data) => ({
  type: SET_PLAYING_STATE,
  playing: data,
});

export const changeSequecePlayListAction = (data) => ({
  type: SET_SEQUECE_PLAYLIST,
  sequencePlayList: data,
});

export const changePlayListAction = (data) => ({
  type: SET_PLAYLIST,
  playList: data,
});

export const changePlayModeAction = (data) => ({
  type: SET_PLAY_MODE,
  mode: data,
});

export const changeCurrentIndexAction = (data) => ({
  type: SET_CURRENT_INDEX,
  currentIndex: data,
});

export const changeShowPlayListAction = (data) => ({
  type: SET_SHOW_PLAYLIST,
  showPlayList: data,
});
export const changeInsertSongAction = (data) => ({
  type: INSERT_SONG,
  
})
export const deleteSongAction= (data) => ({
  type: DELETE_SONG,
  data
});
export const getSongDetail = id => {
  return (dispatch) => {
    getSongDetailRequest(id).then(data => {

      dispatch(changeInsertSongAction(data.songs[0]))
    })
  }
}